$(function(){

   
    function getQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var reg_rewrite = new RegExp("(^|/)" + name + "/([^/]*)(/|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        var q = window.location.pathname.substr(1).match(reg_rewrite);
        if(r != null){
            return unescape(r[2]);
        }else if(q != null){
            return unescape(q[2]);
        }else{
            return null;
        }
    }
    init ()
    function init (){
        couponproductAjax()

        var gallery = mui('.mui-slider');
        gallery.slider({
        interval:1000//自动轮播周期，若为0则不自动播放，默认为0；
            });
    }

    function couponproductAjax (){
        
        $.ajax({
            type: "get",
            url: "http://193.112.55.79:9090/api/getcouponproduct",
            data: {couponid:getQueryString("couponId")},
            dataType: "dataType",
            success: function (response) {
                let data=JSON.parse(response);
                console.log(data);   
                let html=''
                for(let i=0;i<data.result.length;i++){
                    html+= `               
                     <li class="mui-table-view-cell mui-media">
                     <di  class='img_left'>
                    <div class='img_left_con'>
                     <a href="javastript:;" class='imgzz'>
                     ${data.result[i].couponProductImg}
                     </a>
                     
                    </div>   
                     <div class="body_couponProduct"> 
                     <a href="javastript:;">
                     <div class="tite_neirong">${data.result[i].couponProductName}</div>
                     <p>${data.result[i].couponProductPrice}</p>
                     <span class="time_yx">${data.result[i].couponProductTime}</span>
                     </div>
                     </a>           
                     
                    
                     </li>`;

                }

                $('.mui-table-view').html(html);

                $('.mui-table-view').on('tap','.imgzz',function(){
                    console.log(23);
                    // loginbox
                    $('.imgzzs').addClass("bg");
                    $('.lunbo_img').addClass("loginbox");

                });

                // hasClass(‘classname’)

                // $(".removebox1").hasClass("mui-active")
                $('.imgzzs').on('tap',function(){
                    if($(".imgzzs").hasClass('bg')){
                    $('.imgzzs').removeClass("bg");
                    $('.lunbo_img').removeClass("loginbox");


                    }

                })
                // removeClass hasClass

                
                
            }
        });
    }
})